package com.ksc.storekeeper.client.view.components;

import java.util.Iterator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HasCaption;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class FormItem extends Composite implements HasWidgets, HasCaption {

	private static FormItemUiBinder uiBinder = GWT.create(FormItemUiBinder.class);

	interface FormItemUiBinder extends UiBinder<Widget, FormItem> {
	}

	public FormItem() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	@UiField
	Label itemLabel;

	@UiField
	FlowPanel content;

	@Override
	public void add(Widget w) {
		content.add(w);
	}

	@Override
	public void clear() {
		content.clear();
	}

	@Override
	public Iterator<Widget> iterator() {
		return content.iterator();
	}

	@Override
	public boolean remove(Widget w) {
		return content.remove(w);
	}

	@Override
	public String getCaption() {
		return itemLabel.getText();
	}

	@Override
	public void setCaption(String value) {
		itemLabel.setText(value);
	}

}
